import * as Common from '@/config/common.js' //引入common
import request from '@/filter/request.js'

function doSSo(code) {
	var that = this;
	// this.isLogin = uni.getStorageSync('isLogin');
	// if(isLogin){
	//    return;
	// }
	request("S1030", {
			'token': code
		}, 'POST',
		function(res) {
			 console.log(res)
			if (res.data.CODE == 0) {
				console.log(res.data.DATA)
				if (Common.isEmpyt(res.data.DATA)) {
					Common.errorToShow("无法获取用户信息")
					return;
				}
				uni.setStorageSync('isLogin', true);
				uni.setStorageSync('userInfo',Object.assign({},{username:res.data.DATA.LOGIN_ID,password:res.data.DATA.LOGIN_PWD},res.data.DATA));
			
				
				console.log("IS_WS="+res.data.DATA.IS_WS)
				if ('loginInfo', res.data.DATA.IS_WS == '0') {
					uni.navigateTo({
						url: "../fillInfo/fillInfo",
					})
				} else {
					uni.switchTab({
						url: '../index/index'
					});
				}
			} else {
				uni.removeStorageSync("userInfo");
				uni.setStorageSync('isLogin', false);
				Common.errorToShow(res.data.MSG)
			}
		})

}


export {
	doSSo
}
